package com.ibm.risk.irmp.workflow.client.flowable.api;

import com.ibm.risk.irmp.workflow.client.flowable.ApiClient;
import com.ibm.risk.irmp.workflow.client.flowable.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.util.UriComponentsBuilder;

import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Component("com.ibm.risk.irmp.flowable.api.ProcessInstancesApi")
public class ProcessInstancesApi {

    private ApiClient apiClient;


    public ApiClient getApiClient() {
        return apiClient;
    }

    @Autowired
    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Change the state a process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and change state activity was executed.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     * <p><b>409</b> - Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended.
     *
     * @param processInstanceId The processInstanceId parameter
     * @param body              The body parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void changeActivityState(String processInstanceId, ExecutionChangeActivityStateRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling changeActivityState");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}/change-state").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
        };
        apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Start a process instance
     * Note that also a *transientVariables* property is accepted as part of this json, that follows the same structure as the *variables* property.  Only one of *processDefinitionId*, *processDefinitionKey* or *message* can be used in the request body.   Parameters *businessKey*, *variables* and *tenantId* are optional.   If tenantId is omitted, the default tenant will be used. More information about the variable format can be found in the REST variables section.   Note that the variable-scope that is supplied is ignored, process-variables are always local.
     * <p><b>200</b> - successful operation
     * <p><b>201</b> - Indicates the process instance was created.
     * <p><b>400</b> - Indicates either the process-definition was not found (based on id or key), no process is started by sending the given message or an invalid variable has been passed. Status description contains additional information about the error.
     *
     * @param body The body parameter
     * @return ProcessInstanceResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ProcessInstanceResponse createProcessInstance(ProcessInstanceCreateRequest body) throws RestClientException {
        Object postBody = body;

        String path = UriComponentsBuilder.fromPath("/runtime/process-instances").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<ProcessInstanceResponse> returnType = new ParameterizedTypeReference<ProcessInstanceResponse>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Delete a process instance
     *
     * <p><b>204</b> - Indicates the process instance was found and deleted. Response body is left empty intentionally.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     *
     * @param processInstanceId The processInstanceId parameter
     * @param deleteReason      The deleteReason parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void deleteProcessInstance(String processInstanceId, String deleteReason) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling deleteProcessInstance");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "deleteReason", deleteReason));

        final String[] accepts = {};
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
        };
        apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Evaluate the conditions of a process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and the evaluation of the conditions was executed.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     * <p><b>409</b> - Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended.
     *
     * @param processInstanceId The processInstanceId parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void evaluateConditions(String processInstanceId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling evaluateConditions");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}/evaluate-conditions").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
        };
        apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Get a process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and returned.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     *
     * @param processInstanceId The processInstanceId parameter
     * @return ProcessInstanceResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ProcessInstanceResponse getProcessInstance(String processInstanceId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling getProcessInstance");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<ProcessInstanceResponse> returnType = new ParameterizedTypeReference<ProcessInstanceResponse>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Get diagram for a process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and the diagram was returned.
     * <p><b>400</b> - Indicates the requested process instance was not found but the process does not contain any graphical information (BPMN:DI) and no diagram can be created.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     *
     * @param processInstanceId The processInstanceId parameter
     * @return List&lt;byte[]&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public byte[] getProcessInstanceDiagram(String processInstanceId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling getProcessInstanceDiagram");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}/diagram").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {};
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<byte[]> returnType = new ParameterizedTypeReference<byte[]>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Inject activity in a process instance
     *
     * <p><b>200</b> - Indicates the process instance was updated and the activity injection was executed.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     * <p><b>409</b> - Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended.
     *
     * @param processInstanceId The processInstanceId parameter
     * @param body              The body parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void injectActivityInProcessInstance(String processInstanceId, InjectActivityRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling injectActivityInProcessInstance");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}/inject").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
        };
        apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * List process instances
     *
     * <p><b>200</b> - Indicates request was successful and the process-instances are returned
     * <p><b>400</b> - Indicates a parameter was passed in the wrong format . The status-message contains additional information.
     *
     * @param id                             Only return models with the given version.
     * @param name                           Only return models with the given name.
     * @param nameLike                       Only return models like the given name.
     * @param nameLikeIgnoreCase             Only return models like the given name ignoring case.
     * @param processDefinitionKey           Only return process instances with the given process definition key.
     * @param processDefinitionId            Only return process instances with the given process definition id.
     * @param processDefinitionCategory      Only return process instances with the given process definition category.
     * @param processDefinitionVersion       Only return process instances with the given process definition version.
     * @param processDefinitionEngineVersion Only return process instances with the given process definition engine version.
     * @param businessKey                    Only return process instances with the given businessKey.
     * @param businessKeyLike                Only return process instances with the businessKey like the given key.
     * @param startedBy                      Only return process instances started by the given user.
     * @param startedBefore                  Only return process instances started before the given date.
     * @param startedAfter                   Only return process instances started after the given date.
     * @param involvedUser                   Only return process instances in which the given user is involved.
     * @param suspended                      If true, only return process instance which are suspended. If false, only return process instances which are not suspended (active).
     * @param superProcessInstanceId         Only return process instances which have the given super process-instance id (for processes that have a call-activities).
     * @param subProcessInstanceId           Only return process instances which have the given sub process-instance id (for processes started as a call-activity).
     * @param excludeSubprocesses            Return only process instances which are not sub processes.
     * @param includeProcessVariables        Indication to include process variables in the result.
     * @param callbackId                     Only return process instances with the given callbackId.
     * @param callbackType                   Only return process instances with the given callbackType.
     * @param tenantId                       Only return process instances with the given tenantId.
     * @param tenantIdLike                   Only return process instances with a tenantId like the given value.
     * @param withoutTenantId                If true, only returns process instances without a tenantId set. If false, the withoutTenantId parameter is ignored.
     * @param sort                           Property to sort on, to be used together with the order.
     * @return DataResponseProcessInstanceResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public DataResponseProcessInstanceResponse listProcessInstances(String id, String name, String nameLike, String nameLikeIgnoreCase, String processDefinitionKey, String processDefinitionId, String processDefinitionCategory, Integer processDefinitionVersion, String processDefinitionEngineVersion, String businessKey, String businessKeyLike, String startedBy, OffsetDateTime startedBefore, OffsetDateTime startedAfter, String involvedUser, Boolean suspended, String superProcessInstanceId, String subProcessInstanceId, Boolean excludeSubprocesses, Boolean includeProcessVariables, String callbackId, String callbackType, String tenantId, String tenantIdLike, Boolean withoutTenantId, String sort) throws RestClientException {
        Object postBody = null;

        String path = UriComponentsBuilder.fromPath("/runtime/process-instances").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "id", id));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "name", name));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "nameLike", nameLike));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "nameLikeIgnoreCase", nameLikeIgnoreCase));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionKey", processDefinitionKey));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionId", processDefinitionId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionCategory", processDefinitionCategory));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionVersion", processDefinitionVersion));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionEngineVersion", processDefinitionEngineVersion));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "businessKey", businessKey));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "businessKeyLike", businessKeyLike));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "startedBy", startedBy));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "startedBefore", startedBefore));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "startedAfter", startedAfter));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "involvedUser", involvedUser));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "suspended", suspended));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "superProcessInstanceId", superProcessInstanceId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "subProcessInstanceId", subProcessInstanceId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "excludeSubprocesses", excludeSubprocesses));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "includeProcessVariables", includeProcessVariables));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "callbackId", callbackId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "callbackType", callbackType));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "tenantId", tenantId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "tenantIdLike", tenantIdLike));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "withoutTenantId", withoutTenantId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "sort", sort));

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<DataResponseProcessInstanceResponse> returnType = new ParameterizedTypeReference<DataResponseProcessInstanceResponse>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Migrate process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and migration was executed.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     * <p><b>409</b> - Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended.
     *
     * @param processInstanceId The processInstanceId parameter
     * @param body              The body parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void migrateProcessInstance(String processInstanceId, String body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling migrateProcessInstance");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}/migrate").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {
        };
        apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Activate or suspend a process instance
     *
     * <p><b>200</b> - Indicates the process instance was found and action was executed.
     * <p><b>400</b> -   Indicates an invalid action was supplied.
     * <p><b>404</b> - Indicates the requested process instance was not found.
     * <p><b>409</b> - Indicates the requested process instance action cannot be executed since the process-instance is already activated/suspended.
     *
     * @param processInstanceId The processInstanceId parameter
     * @param body              The body parameter
     * @return ProcessInstanceResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ProcessInstanceResponse performProcessInstanceAction(String processInstanceId, ProcessInstanceActionRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'processInstanceId' is set
        if (processInstanceId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'processInstanceId' when calling performProcessInstanceAction");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("processInstanceId", processInstanceId);
        String path = UriComponentsBuilder.fromPath("/runtime/process-instances/{processInstanceId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<ProcessInstanceResponse> returnType = new ParameterizedTypeReference<ProcessInstanceResponse>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }

    /**
     * Query process instances
     * The request body can contain all possible filters that can be used in the List process instances URL query. On top of these, it’s possible to provide an array of variables to include in the query, with their format described here.  The general paging and sorting query-parameters can be used for this URL.
     * <p><b>200</b> - Indicates request was successful and the process-instances are returned
     * <p><b>400</b> - Indicates a parameter was passed in the wrong format . The status-message contains additional information.
     *
     * @param body The body parameter
     * @return DataResponseProcessInstanceResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public DataResponseProcessInstanceResponse queryProcessInstances(ProcessInstanceQueryRequest body) throws RestClientException {
        Object postBody = body;

        String path = UriComponentsBuilder.fromPath("/query/process-instances").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
                "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {};
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[]{"basicAuth"};

        ParameterizedTypeReference<DataResponseProcessInstanceResponse> returnType = new ParameterizedTypeReference<DataResponseProcessInstanceResponse>() {
        };
        return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
}
